#!/usr/bin/env node


const fs=require('fs'),
      file=process.argv[2];

if(process.argv.length!=3){
  console.error('参数格式不正确,应为：cmd fileName');
  process.exit(1);
}

let buf;

try {
    buf = fs.readFileSync(file);

} catch(e) {
    console.error(e.message);
    process.exit(2);
}

if(buf.toString('ascii',0,2) === 'BM') {
    console.log('width:',buf.readInt32LE(0x12));
    console.log('height:',buf.readInt32LE(0x16));
    console.log('color depth:',buf.readUInt16LE(0x1c));

}
